import React from 'react'
import { ActivityIndicator } from 'antd-mobile'
import './index.less'
import {withRouter} from "react-router-dom";

const Loading = (props) => {
  console.warn('loading', props)
  console.warn('loading error', props.error)

  if(props.error&&props.error.message.indexOf("Loading chunk")!==-1 && props.error.message.indexOf('failed')!==-1){

    let url = props.location.pathname+props.location.search+props.location.hash
    console.warn('redirect', url)
    window.location = url
    return null
  }

  return (
    <div className="CommonLoadingContainer">
      <div className="loading-example">
        <div className="align">
          <ActivityIndicator size="large"/>
        </div>
      </div>
    </div>
  )
}

export default withRouter(Loading)
